package model;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Push {
	
	// Attributs
	
		// Constructor
		public Push(String nickname, String msg) throws IOException {
			
			String message = msg;
			message = message.replaceAll(" ", "%20");
			String urlString = "http://pushme.to/z/ajax/pushme/?nickname="+nickname+
								"&signature="+"eConf"+
								"&message="+msg;
//			System.out.println(urlString);
			get(urlString);
//			System.out.println("Find sendPush");
		}
		
		
		public static String get(String url) throws IOException{
			String source ="";
			URL oracle = new URL(url);
			URLConnection yc = oracle.openConnection();
			BufferedReader in = new BufferedReader(
			new InputStreamReader(
			yc.getInputStream()));
			String inputLine;
			
			while ((inputLine = in.readLine()) != null)
			source +=inputLine;
			in.close();
			return source;
		}

}
